package com.qjc.demo.train.strmatch;

/**
 * @ClassName: BFMatch
 * @Description: 字符串匹配-暴力匹配算法
 * 时间复杂度是 O(n*m)
 * m:为匹配串长度
 * n:为主串长度
 * @Author: qjc
 * @Date: 2022/5/2 4:06 PM
 */
public class BFMatch {

    public static boolean isMatch(String main, String sub) {
        for (int i = 0; i <= (main.length() - sub.length()); i++) {
            if (main.substring(i, i + sub.length()).equals(sub)) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(isMatch("sdafsdfasdf", "fs"));
    }

}
